<?php
/**
 * Description of OrderAction
 * @author LeDat
 * refer to Nr Aziz (http://www.yiiframework.com/extension/ordercolumn/)
 */
class OrderAction extends CAction {

  public $modelClass;

  public function run($pk1, $pk2, $move)
  {
    if ($pk1 != $pk2)
    {
      $model = CActiveRecord::model($this->modelClass);
      
      if ( ($move == 'up') || ($move == 'down') )
        $model->swapSortOrder($pk1, $pk2);
      elseif ($move == 'top')
        $model->sortMakeTop($pk1, $pk2);
      else
        $model->sortMakeBottom($pk1, $pk2);
    }

    return true;
  }
}